<template>
    <div>
<h1>权益显示</h1>
<a href="/addqy">权益添加</a>
<table class="table">
<thead>
    <tr>
        <td>权益id</td>
        <td>权益名称</td>
        <td>权益状态</td>
        <td>逻辑删除</td>
        <td>操作</td>
    </tr>
</thead>
<tbody>
    <tr v-for="a in da">
        <td>{{a.qId}}</td>
        <td>{{a.qyName}}</td>
        <td>{{a.qyState?"启用":"禁用"}}</td>
        <td>{{ a.qyIsdel }}</td>
        <td>
            <input type="button" :value="a.qyState==true?'禁用':'启用'" @click="gai(a.qId)">
            <input type="button" value="移除" @click="shan(a.qId)">
            <input type="button" value="修改" @click="xiu(a.qId)">
        </td>
    </tr>
</tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import Showhy from '../HuiYuan/Showhy.vue';
const router=useRouter()
onMounted(()=>{
    show()
})
//该状态
const gai=(xx:any)=>{

    if(!confirm("确定？")){
    return
}

 axios.get("https://localhost:7127/api/Qy/GaiZT",{params:{id:xx}}).then(res=>{
    if(res.data>0){
            alert("状态修改成功")
            show()
        }
        else{
            alert("状态修改失败")
        }
 })
}
//删除
const shan=(xx:any)=>{
if(!confirm("确定？")){
    return
}

    axios.delete("https://localhost:7127/api/Qy/ShanQy",{params:{id:xx}}).then(res=>{
        if(res.data>0){
            alert("移除成功")
            show()
        }
        else{
            alert("移除失败")
        }
    })
}

//修改
const xiu=(xx:any)=>{
    if(!confirm("确定？")){
    return
}


    router.push({path:'/fanqy',query:{id:xx}})
}

//m
const da=ref([{
    "qId": 0,
    "qyName": "",
    "qyState": true,
    "qyIsdel": 0
  }])

  const show=()=>{
    axios.get("https://localhost:7127/api/Qy/GetAllQyModels").then(res=>{
        da.value=res.data
    })
  }
</script>

<style scoped>

</style>